home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / SUB_ARCT / DEMO_APP / SEPARATO.JAV < prev    next >
Encoding:
Text File  |  1996-10-04  |  2.4 KB  |  92 lines

  1. package sub_arctic.demo_apps;
  2.  
  3. import sub_arctic.lib.base_interactor;
  4. import sub_arctic.lib.manager;
  5. import sub_arctic.input.simple_press_draggable;
  6. import sub_arctic.input.event;
  7. import sub_arctic.output.drawable;
  8.  
  9. /**
  10.  * This little class implements a draggable separator which can be
  11.  * configured to move only in x or y.
  12.  */
  13. public class separator extends base_interactor implements simple_press_draggable {
  14.   /* are we x or y? */
  15.   boolean in_x;
  16.  
  17.   /**
  18.    * Create a separator. We assume you are going to constrain the 
  19.    * relevant layout attributes other than its width .
  20.    */
  21.   public separator(int w, int h, boolean separate_in_x) {
  22.     super(0,0,w,h);
  23.     in_x=separate_in_x;
  24.   }
  25.   /*
  26.    * Reposition this object, given an event.
  27.    */
  28.   public void reposition(event evt) {
  29.     if (in_x) {
  30.       set_x(x_into_parent(evt.local_x()));
  31.     } else {
  32.       set_y(y_into_parent(evt.local_y()));
  33.     }
  34.   }
  35.   /**
  36.    * Start a drag
  37.    */
  38.   public boolean drag_start(event evt, Object user_info) {
  39.     /* marker needs to be drawn */
  40.     reposition(evt);
  41.     return true;
  42.   }
  43.   /**
  44.    * continue a drag
  45.    */
  46.   public boolean drag_feedback(event evt, Object user_info) {
  47.     reposition(evt);
  48.     return true;
  49.   }
  50.   /**
  51.    * Start a drag
  52.    */
  53.   public boolean drag_end(event evt, Object user_info) {
  54.     reposition(evt);
  55.     return true;
  56.   }
  57.   /**
  58.    * Draw a visual indicator 
  59.    */
  60.   public void draw_self_local(drawable d)  {
  61.     if (in_x) {
  62.       /* top handle */
  63.       d.fillRect(1,1,w()-2,5);
  64.       /* line in the middle */
  65.       d.drawLine(w()/2,1,w()/2,h()-2);
  66.       /* bottom handle */
  67.       d.fillRect(1,h()-6,w()-2,5);
  68.     } else {
  69.       /* left handle */
  70.       d.fillRect(1,1,5,h()-2);
  71.       d.drawLine(1,h()/2,w()-2,h()/2);
  72.       d.fillRect(w()-6,1,5,h()-2);
  73.     }
  74.   }
  75. }
  76. /*=========================== COPYRIGHT NOTICE ===========================
  77.  
  78. This file is part of the subArctic user interface toolkit.
  79.  
  80. Copyright (c) 1996 Scott Hudson and Ian Smith
  81. All rights reserved.
  82.  
  83. The subArctic system is freely available for most uses under the terms
  84. and conditions described in 
  85.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  86. and appearing in full in the lib/interactor.java source file.
  87.  
  88. The current release and additional information about this software can be 
  89. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  90.  
  91. ========================================================================*/
  92.